﻿using DoubanFM.Model;

namespace DoubanFM.ViewModel
{
    /// <summary>
    /// Channel item view model.
    /// </summary>
    public class ChannelItemViewModel : ViewModelCommon
    {
        public ChannelItemViewModel(Channel channel, ChannelGroupViewModel group)
            : base(channel.Id.ToString(), channel.Name + " MHz", channel.Cover, channel.Banner, GetDescription(channel.SongNum, channel.Creator.Name))
        {
            _songNum = channel.SongNum;
            _creator = channel.Creator.Name;
            _group = group;
        }

        private long _songNum;
        public long SongNum
        {
            get { return _songNum; }
            set
            {
                SetProperty(ref _songNum, value);
                Description = GetDescription(_songNum, _creator);
            }
        }

        private string _creator = string.Empty;
        public string Creator
        {
            get { return _creator; }
            set
            {
                SetProperty(ref _creator, value);
                Description = GetDescription(_songNum, _creator);
            }
        }

        private ChannelGroupViewModel _group;
        public ChannelGroupViewModel Group
        {
            get { return _group; }
            set { SetProperty(ref _group, value); }
        }

        private static string GetDescription(long songNum, string creator)
        {
            return songNum + "\u9996\u6B4C\u66F2  " + creator + "\u5236\u4F5C";
        }
    }
}
